<?php
defined('_JEXEC') or die;

JHtml::_('behavior.keepalive');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');

?>
<script>

function buscar_departamentos(){
	ajaxpage2('index.php?option=com_base&tmpl=component&task=departamentos.select&onchange=buscar_ciudades&idpais='+$("jform_idpais").value,'div_iddepartamento');
}

function buscar_ciudades(){
	ajaxpage2('index.php?option=com_base&tmpl=component&task=ciudades.select&iddepartamento='+$("jform_iddepartamento").value,'div_idciudad');
}

</script>
<?php

?>
<div class="registration<?php echo $this->pageclass_sfx?>">
<?php if ($this->params->get('show_page_heading')) : ?>
	<h1><?php echo $this->escape($this->params->get('page_heading')); ?></h1>
<?php endif; ?>

	<form id="member-registration" action="index.php?option=com_base&task=comunas.guardar" method="post" class="form-validate">
	
<?php foreach ($this->form->getFieldsets() as $fieldset){} ?>

		<fieldset>
		
			<legend> <?php echo JText::_($fieldset->label);?></legend>
			<?php echo $this->form->getInput('idcomuna'); ?>
		<dl>
			<dt><?php echo $this->form->getLabel('idpais'); ?></dt>
			<dd><?php echo $this->form->getInput('idpais'); ?></dd>
		</dl>
		
		<dl>
			<dt><?php echo $this->form->getLabel('iddepartamento'); ?></dt>
			
			<div id="div_iddepartamento">
				<dd><?php echo $this->form->getInput('iddepartamento'); ?></dd>
			</div>
			
		</dl>
		
		<dl>
			<dt><?php echo $this->form->getLabel('idciudad'); ?></dt>
			
			<div id="div_idciudad">
				<dd><?php echo $this->form->getInput('idciudad'); ?></dd>
			</div>
			
		</dl>
		
		<dl>
			<dt><?php echo $this->form->getLabel('comuna'); ?></dt>
			<dd><?php echo $this->form->getInput('comuna'); ?></dd>
		</dl>
		<dl>
			<dt><?php echo $this->form->getLabel('idestado'); ?> <span class="optional">(Opcional)</span> </dt>
			<dd><?php echo $this->form->getInput('idestado'); ?></dd>
		</dl>
		
		
		</fieldset>
		
		<div>
			<button type="submit" class="validate">Guardar</button>
			
			<a href="Javascript:void(0);" onclick="window.parent.SqueezeBox.close();" >Cancelar</a>
			
			<input type="hidden" name="option" value="com_base" />
			<input type="hidden" name="task" value="comunas.guardar" />
			<?php echo JHtml::_('form.token');?>
		</div>
	</form>
</div>
